<template>
  <div id="app">
    <!-- 条件渲染导航栏和侧边栏 -->
    <nav v-if="$route.path !== '/login'" class="navbar">
      <div class="navbar-left">
        <router-link to="/" class="home-link">
          <i class="fas fa-home mr-1"></i>首页
        </router-link>
      </div>
      <div class="navbar-center">
        <span class="platform-title">乡村文化遗产数字化保护平台</span>
      </div>
    </nav>

    <!-- 侧边栏容器 -->
    <div v-if="$route.path !== '/login'" class="sidebar-container">
      <SideBar />
    </div>

    <!-- 主内容区域 -->
    <div class="main-content">
      <div class="container">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import SideBar from './components/SideBar.vue'

export default {
  name: 'App',
  components: {
    SideBar
  }
}
</script>

<style scoped>
/* App全局样式 */
#app {
  min-height: 100vh;
  background-color: #f8f9fa;
}

/* 导航栏样式 */
.navbar {
  background-color: #2c3e50;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.navbar-left, .navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-center {
  font-size: 1.5rem;
  color: white;
  font-weight: 500;
}

.home-link {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.home-link:hover {
  color: #ddd;
  text-decoration: none;
}

.user-info {
  margin-right: 1rem;
  color: white;
}

.logout-btn {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.logout-btn:hover {
  color: #ddd;
  text-decoration: none;
}

.platform-title {
  letter-spacing: 1px;
}

/* 侧边栏容器样式 */
.sidebar-container {
  position: fixed;
  top: 60px; /* 与导航栏高度相匹配 */
  left: 0;
  bottom: 0;
  width: 250px;
  z-index: 999;
}

/* 主内容区域样式 */
.main-content {
  padding: 1rem;
  transition: margin 0.3s ease;
}

/* 当导航栏和侧边栏都存在时的样式 */
.navbar + .sidebar-container + .main-content {
  margin-top: 60px;
  margin-left: 250px;
}

/* 当只有导航栏时的样式 */
.navbar + .main-content {
  margin-top: 60px;
}

/* 当只有侧边栏时的样式 */
.sidebar-container + .main-content {
  margin-left: 250px;
}

.container {
  padding: 1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar-container {
    width: 70px;
  }

  .main-content {
    margin-left: 70px;
    padding-left: 1rem;
  }
}

@media (max-width: 991.98px) {
  .container {
    padding: 0 1rem;
  }
}

/* 欢迎区域样式 */
.welcome-section {
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.7)),
    url('https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1600&h=900');
  background-size: cover;
  background-position: center;
  color: white;
  padding: 150px 0;
  margin: -1rem -1rem 2rem -1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* 功能卡片样式 */
.feature-card {
  transition: transform 0.3s ease;
  height: 100%;
  border: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.feature-card:hover {
  transform: translateY(-5px);
}

/* 按钮样式 */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transition: all 0.3s ease;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  color: white;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover {
  background-color: #2980b9;
  border-color: #2980b9;
  transform: translateY(-2px);
}

/* 页脚样式 */
.footer {
  background-color: #333;
  color: white;
  padding: 3rem 2rem 1rem;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3 {
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-link {
  color: white;
  text-decoration: none;
  transition: color 0.3s ease;
}

.social-link:hover {
  color: var(--primary-color);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
</style>
